file57 <- readRDS("survey_35172.rds")
file58 <- readRDS("survey_37077.rds")
file59 <- readRDS("survey_43567.rds")
files <- list(file1 = file1, file2 = file2, file3 = file3, file4 = file4,
file5 = file5, file6 = file6, file7 = file7, file8 = file8, file9 = file9,
file10 = file10, file11 = file11, file12 = file12, file13 = file13,
file14 = file14, file15 = file15, file16 = file16, file17 = file17,
file18 = file18,
file19 = file19, file20 = file20, file21 = file21, file22 = file22,
file23 = file23, file24 = file24, file25 = file25, file26 = file26,
file27 = file27, file28 = file28, file29 = file29, file30 = file30,
file31 = file31, file32 = file32, file33 = file33, file34 = file34,
file35 = file35, file36 = file36, file37 = file37, file38 = file38,
file39 = file39, file40 = file40, file41 = file41, file42 = file42,
file43 = file43, file44 = file44, file45 = file45, file46 = file46,
file47 = file47, file48 = file48, file49 = file49, file50 = file50,
file51 = file51, file52 = file52,
file53 = file53, file54 = file54, file55 = file55, file56 = file56,
file57 = file57, file58 = file58, file59 = file59)
require("plyr")
data <- ldply(files, data.frame)
sum(is.na(file16))
sum(is.na(data[data$study == 2434,]))
View(data)
summary(file16)
sum(is.na(file16))
summary(file17)
table(file17$study)
sum(is.na(data[data$study == 2624N,]))
sum(is.na(data[data$study == "2624N",]))
sum(is.na(file17))
nrow(data[data$study == "2624N"])
nrow(data[data$study == "2624N",])
nrow(file17)
table(file18$study)
sum(is.na(data[data$study == "2434",]))
sum(is.na(file18))
nrow(data[data$study == "2434",])
nrow(file18)
file18$study
table(file19$study)
names(files)
nrow(dataframe)
dataframe <- data.frame()
nrow(dataframe)
files[names(files)[1]]
print(4)
i <- 1
test1 <- nrow(dataframe)
test2 <- nrow(files[names(files[i])])
dataframe <- rbind(dataframe, files[names(files[i])])
test3 <- nrow(dataframe)
print(i)
print(test3 - test1 == test2)
test3
test1
test2
nrow(files[names(files[i])])
str(files[names(files[i])])
nrow(files[names(files[i])][[1]])
i <- 1
test1 <- nrow(dataframe)
test2 <- nrow(files[names(files[i])][[1]])
dataframe <- rbind(dataframe, files[names(files[i])][[1]])
?data.frame
dataframe <- file1
i <- 2
test1 <- nrow(dataframe)
test2 <- nrow(files[names(files[i])][[1]])
dataframe <- rbind(dataframe, files[names(files[i])][[1]])
test3 <- nrow(dataframe)
print(i)
print(test3 - test1 == test2)
for(i in 2:names(files)){
test1 <- nrow(dataframe)
test2 <- nrow(files[names(files[i])][[1]])
dataframe <- rbind(dataframe, files[names(files[i])][[1]])
test3 <- nrow(dataframe)
print(i)
print(test3 - test1 == test2)
}
2:length(names(files))
dataframe <- file1
for(i in 2:length(names(files))){
test1 <- nrow(dataframe)
test2 <- nrow(files[names(files[i])][[1]])
dataframe <- rbind(dataframe, files[names(files[i])][[1]])
test3 <- nrow(dataframe)
print(i)
print(test3 - test1 == test2)
}
dim(dataframe)
table(file16$study)
table(file18$study)
summary(datafrmae)
summary(dataframe)
table(data$urban)
table(dataframe$urban)
table(dataframe$study[dataframe$urban == "Central city" | dataframe$urban == "Central City" |
dataframe$urban == "Suburb"])
setwd("~/Dropbox/Perception_Inequality_wHannah/Survey Files/Harris 1972 Miami Presidential Election Survey, study no. 2233")
library(dplyr)
library(tidyr)
library(car)
library(readstata13)
survey <- read.dta13("harris_s2233_spss.dta")
# pid
survey$pid <- c(1:nrow(survey))
# study
survey$study <-2233
# study year (year)
survey$year <- 1972
# geographic data (urban)
survey$urban <- car::recode(survey$S13, "'Central city' = 'Urban'; 'Town' = 'Rural';
'Suburb' = 'Suburb'; 'Rural' = 'Rural'")
# geographic data (region)
survey$region <- survey$S11
levels(survey$region) <- list(East=c("East_(1)", "East_(2)"), Midwest=c("Midwest_(5)", "Midwest_(6)"),
South=c("South_(3)", "South_(4)"),
West=c("West_(7)", "West_(8)"))
class(survey$region)
# respondent head of household (hh)
survey$hh <- car::recode(survey$F2A, "'Male head' = 'Yes'; 'Female head (no male head)' = 'Yes';
'Wife' = 'No'; 'Son' = 'No'; 'Daughter' = 'No'; 'Other (specify)' = 'No';
else = 'NA'")
survey$hh <- as.factor(survey$hh)
# increasing inequality (inequality)
survey$inequality <- car::recode(survey$P12_A, "'Don t Feel' = 'Don t feel'; 'Not Sure' = 'Not sure'")
# inequality variable (inequality.variable)
survey$inequality.variable <- 1
# union (union.self)
survey$union.self <- survey$F6_1 # already harmonized
# union (union.other) question is "no union member in family?"
survey$union.other <- car::recode(survey$F6_3, "'Yes' = 'No'; 'No' = 'Yes'; else = 'NA'")
# employment (employed)
survey$employed <- survey$F2B
# occupation
survey$occupation <- survey$F2C
# household size (hhsize)
survey$hhsize <- NA
# education (educ)
survey$educ <- car::recode(survey$F5, "c('8th grade or less', 'Some high school') = 'Less than high school';
'2-yr cllg grdt (cmmnty, tc )' = 'Some college'; '4-year college graduate' = 'College graduate'")
survey$educ <- factor(survey$educ, levels = c("Less than high school", "High school graduate", "Some college", "College graduate", "Post graduate"),
labels = c("Less than high school", "High school graduate", "Some college", "College graduate", "Post graduate"),
ordered = TRUE)
# household income (income)
survey$income <- survey$F9
# age
survey$age <- survey$P1E
# race
survey$race <- survey$F10
# politics (party)
survey$party <- survey$P1C
# politics (ideology)
survey$ideology <- NA
# gender
survey$gender <- survey$F11
# religion
survey$religion <- survey$F7
# subset
survey_2233 <- survey[,c("pid", "study", "year", "urban", "region", "hh",
"inequality", "inequality.variable", "union.self", "union.other",
"employed", "occupation", "hhsize", "educ", "income",
"age", "race", "party", "ideology", "gender", "religion")]
summary(survey_2233)
saveRDS(survey_2233, file = "survey_2233.rds")
#Harris 1972 Presidential Election and Economic Outlook Survey, study no. 2235
setwd("~/Dropbox/Perception_Inequality_wHannah/Survey Files/Harris 1972 Presidential Election and Economic Outlook Survey, study no. 2235")
## packages
require("SASxport")
require("dplyr")
require("readstata13")
## download data
survey <- read.dta13("harris_s2235_spss.dta")
View(survey)
## pid
survey$pid <- c(1:nrow(survey))
class(survey$pid)
## study number
survey$study <- 2235
class(survey$study)
## year
survey$year <- 1972
class(survey$year)
## geographpic data
survey$urban <- survey$S13
summary(survey$urban)
summary(survey$S13)
survey$urban <- recode(survey$urban, `Central city` = "Urban",
`Suburb` = "Suburban", `Town` = "Rural")
## region
survey$region <- survey$S11
summary(survey$region)
summary(survey$S11)
survey$region <- recode(survey$region, `East_(1)` = "East",
`East_(2)` = "East", `South_(3)` = "South",
`South_(4)` = "South", `Midwest_(5)` = "Midwest",
`Midwest_(6)` = "Midwest", `West_(7)` = "West",
`West_(8)` = "West")
## respondent name
summary(survey$F1)
survey$hh <- survey$F1
survey$hh <- recode(survey$hh, `Male head` = "Yes",
`Female head (no male head)` = "Yes", `Wife` = "No",
`Son` = "No", `Daughter` = "No", `Other (specify)` = "No")
summary(survey$hh)
## inequality increasing
summary(survey$P6_A)
survey$inequality <- survey$P6_A
survey$inequality <- recode(survey$inequality,
`Don t feel` = "Don't Feel",
`Not sure` = "Not Sure")
summary(survey$inequality)
class(survey$inequality)
is.ordered(survey$inequality)
## inequality variable version
survey$inequality.variable <- 1
class(survey$inequality.variable)
colnames(survey)
## union
summary(survey$F10_4) # not sure
table(survey$F10_4, survey$F10_1)
survey$union.self <- as.character(survey$F10_1)
survey$union.self[survey$F10_4 == "Yes"] <- "Not Sure"
survey$union.self <- factor(survey$union.self)
survey$union.other <- as.character(survey$F10_2)
survey$union.other[survey$F10_4 == "Yes"] <- "Not Sure"
survey$union.other <- factor(survey$union.other)
## Are you employed? what kind of employment?
summary(survey$F2A)
survey$employed <- survey$F2A
class(survey$employed)
## Occupation
summary(survey$F2B)
survey$occupation <- survey$F2B
class(survey$occupation)
## household size
survey$hhsize <- NA
## Education
summary(survey$F8)
survey$educ <- survey$F8
summary(survey$educ)
survey$educ <- recode(survey$educ, `8th grade or less` = "Less than high school",
`Some high school` = "Less than high school",
`Some high school (9th-11th grade)` = "Less than high school",
`2-year college grad (community, etc )` = "Some college",
`4-year college graduate` = "College graduate")
class(survey$educ)
summary(survey$educ)
survey$educ <- as.ordered(survey$educ)
## Income
summary(survey$F9)
survey$income <- survey$F9
summary(survey$income)
class(survey$income)
## Age
summary(survey$P1E)
survey$age <- survey$P1E
summary(survey$age)
## race
summary(survey$F11)
survey$race <- survey$F11
summary(survey$race)
## politics
survey$party <- survey$P1C
summary(survey$party)
class(survey$party)
## ideology
survey$ideology <- NA
summary(survey$ideology)
## gender
summary(survey$F12)
survey$gender <- survey$F12
table(survey$gender)
## religion
survey$religion <- survey$F3
summary(survey$religion)
### put together data set
survey_2235 <- survey[,c("pid", "study", "year", "urban", "region", "hh",
"inequality", "inequality.variable", "union.self", "union.other",
"employed", "occupation", "hhsize", "educ", "income",
"age", "race", "party", "ideology", "gender", "religion")]
summary(survey_2235)
#Harris 1972 Presidential Election and Economic Outlook Survey, study no. 2235
setwd("~/Dropbox/Perception_Inequality_wHannah/Survey Files/Harris 1972 Presidential Election and Economic Outlook Survey, study no. 2235")
## packages
require("SASxport")
require("dplyr")
require("readstata13")
## download data
survey <- read.dta13("harris_s2235_spss.dta")
View(survey)
## pid
survey$pid <- c(1:nrow(survey))
class(survey$pid)
## study number
survey$study <- 2235
class(survey$study)
## year
survey$year <- 1972
class(survey$year)
## geographpic data
survey$urban <- survey$S13
summary(survey$urban)
summary(survey$S13)
survey$urban <- recode(survey$urban, `Central city` = "Urban",
`Suburb` = "Suburban", `Town` = "Rural")
## region
survey$region <- survey$S11
summary(survey$region)
summary(survey$S11)
survey$region <- recode(survey$region, `East_(1)` = "East",
`East_(2)` = "East", `South_(3)` = "South",
`South_(4)` = "South", `Midwest_(5)` = "Midwest",
`Midwest_(6)` = "Midwest", `West_(7)` = "West",
`West_(8)` = "West")
## respondent name
summary(survey$F1)
survey$hh <- survey$F1
survey$hh <- recode(survey$hh, `Male head` = "Yes",
`Female head (no male head)` = "Yes", `Wife` = "No",
`Son` = "No", `Daughter` = "No", `Other (specify)` = "No")
summary(survey$hh)
## inequality increasing
summary(survey$P6_A)
survey$inequality <- survey$P6_A
survey$inequality <- recode(survey$inequality,
`Don t feel` = "Don't Feel",
`Not sure` = "Not Sure")
summary(survey$inequality)
class(survey$inequality)
is.ordered(survey$inequality)
## inequality variable version
survey$inequality.variable <- 1
class(survey$inequality.variable)
colnames(survey)
## union
summary(survey$F10_4) # not sure
table(survey$F10_4, survey$F10_1)
survey$union.self <- as.character(survey$F10_1)
survey$union.self[survey$F10_4 == "Yes"] <- "Not Sure"
survey$union.self <- factor(survey$union.self)
survey$union.other <- as.character(survey$F10_2)
survey$union.other[survey$F10_4 == "Yes"] <- "Not Sure"
survey$union.other <- factor(survey$union.other)
## Are you employed? what kind of employment?
summary(survey$F2A)
survey$employed <- survey$F2A
class(survey$employed)
## Occupation
summary(survey$F2B)
survey$occupation <- survey$F2B
class(survey$occupation)
## household size
survey$hhsize <- NA
## Education
summary(survey$F8)
survey$educ <- survey$F8
summary(survey$educ)
survey$educ <- recode(survey$educ, `8th grade or less` = "Less than high school",
`Some high school` = "Less than high school",
`Some high school (9th-11th grade)` = "Less than high school",
`2-year college grad (community, etc )` = "Some college",
`4-year college graduate` = "College graduate")
class(survey$educ)
summary(survey$educ)
survey$educ <- as.ordered(survey$educ)
## Income
summary(survey$F9)
survey$income <- survey$F9
summary(survey$income)
class(survey$income)
## Age
summary(survey$P1E)
survey$age <- survey$P1E
summary(survey$age)
## race
summary(survey$F11)
survey$race <- survey$F11
summary(survey$race)
## politics
survey$party <- survey$P1C
summary(survey$party)
class(survey$party)
## ideology
survey$ideology <- NA
summary(survey$ideology)
## gender
summary(survey$F12)
survey$gender <- survey$F12
table(survey$gender)
## religion
survey$religion <- survey$F3
summary(survey$religion)
### put together data set
survey_2235 <- survey[,c("pid", "study", "year", "urban", "region", "hh",
"inequality", "inequality.variable", "union.self", "union.other",
"employed", "occupation", "hhsize", "educ", "income",
"age", "race", "party", "ideology", "gender", "religion")]
summary(survey_2235)
survey <- read.dta13("harris_s2235_spss.dta")
View(survey)
## pid
survey$pid <- c(1:nrow(survey))
class(survey$pid)
## study number
survey$study <- 2235
class(survey$study)
## year
survey$year <- 1972
class(survey$year)
## geographpic data
survey$urban <- survey$S13
summary(survey$urban)
summary(survey$S13)
survey$urban <- recode(survey$urban, `Central City` = "Urban",
`Suburb` = "Suburban", `Town` = "Rural")
## region
survey$region <- survey$S11
summary(survey$region)
summary(survey$S11)
survey$region <- recode(survey$region, `East_(1)` = "East",
`East_(2)` = "East", `South_(3)` = "South",
`South_(4)` = "South", `Midwest_(5)` = "Midwest",
`Midwest_(6)` = "Midwest", `West_(7)` = "West",
`West_(8)` = "West")
## respondent name
summary(survey$F1)
survey$hh <- survey$F1
survey$hh <- recode(survey$hh, `Male head` = "Yes",
`Female head (no male head)` = "Yes", `Wife` = "No",
`Son` = "No", `Daughter` = "No", `Other (specify)` = "No")
summary(survey$hh)
## inequality increasing
summary(survey$P6_A)
survey$inequality <- survey$P6_A
survey$inequality <- recode(survey$inequality,
`Don t feel` = "Don't Feel",
`Not sure` = "Not Sure")
summary(survey$inequality)
class(survey$inequality)
is.ordered(survey$inequality)
## inequality variable version
survey$inequality.variable <- 1
class(survey$inequality.variable)
colnames(survey)
## union
summary(survey$F10_4) # not sure
table(survey$F10_4, survey$F10_1)
survey$union.self <- as.character(survey$F10_1)
survey$union.self[survey$F10_4 == "Yes"] <- "Not Sure"
survey$union.self <- factor(survey$union.self)
survey$union.other <- as.character(survey$F10_2)
survey$union.other[survey$F10_4 == "Yes"] <- "Not Sure"
survey$union.other <- factor(survey$union.other)
## Are you employed? what kind of employment?
summary(survey$F2A)
survey$employed <- survey$F2A
class(survey$employed)
## Occupation
summary(survey$F2B)
survey$occupation <- survey$F2B
class(survey$occupation)
## household size
survey$hhsize <- NA
## Education
summary(survey$F8)
survey$educ <- survey$F8
summary(survey$educ)
survey$educ <- recode(survey$educ, `8th grade or less` = "Less than high school",
`Some high school` = "Less than high school",
`Some high school (9th-11th grade)` = "Less than high school",
`2-year college grad (community, etc )` = "Some college",
`4-year college graduate` = "College graduate")
class(survey$educ)
summary(survey$educ)
survey$educ <- as.ordered(survey$educ)
## Income
summary(survey$F9)
survey$income <- survey$F9
summary(survey$income)
class(survey$income)
## Age
summary(survey$P1E)
survey$age <- survey$P1E
summary(survey$age)
## race
summary(survey$F11)
survey$race <- survey$F11
summary(survey$race)
## politics
survey$party <- survey$P1C
summary(survey$party)
class(survey$party)
## ideology
survey$ideology <- NA
summary(survey$ideology)
## gender
summary(survey$F12)
survey$gender <- survey$F12
table(survey$gender)
## religion
survey$religion <- survey$F3
summary(survey$religion)
### put together data set
survey_2235 <- survey[,c("pid", "study", "year", "urban", "region", "hh",
"inequality", "inequality.variable", "union.self", "union.other",
"employed", "occupation", "hhsize", "educ", "income",
"age", "race", "party", "ideology", "gender", "religion")]
summary(survey_2235)
saveRDS(survey_2235, file = "survey_2235.rds")
